<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddOrderUploadIndexInOrderTaskFileListTable extends AbstractMigration
{
    public function up()
    {
        $this->table('order_task_file_list')
            ->addIndex(['from_tenant_id', 'task_id'], ['type' => 'normal', 'name' => 'idx_ftenant_task'])
            ->addIndex(['to_tenant_id', 'task_id'], ['type' => 'normal', 'name' => 'idx_ttenant_task'])
            ->save();
        $this->table('order_task_upstream_version')
            ->addIndex(['from_tenant_id', 'task_id', 'version_id'], ['type' => 'normal', 'name' => 'idx_ftenant_task_version'])
            ->save();
    }

    public function down()
    {
        $this->table('order_task_file_list')
            ->removeIndexByName('idx_ftenant_task')
            ->removeIndexByName('idx_ttenant_task')->save();
        $this->table('order_task_upstream_version')->removeIndexByName('idx_ftenant_task_version')->save();
    }
}
